# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=rtmidi
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.0.0
pkgrel=2
pkgdesc="A set of C++ classes that provides a common API for realtime MIDI input/output (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://www.music.mcgill.ca/~gary/rtmidi/"
license=('custom:RtMidi')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
options=('staticlibs' 'strip')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/thestk/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('c7923e4eee82b06c007435892cb2c3212d9007fa482c6b718943bda71c02c5a7')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --with-winmm \
      --with-winks

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
